//
//  TFLargeLiveSetCenter.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/4/20.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFLargeLiveSetCenter: UIView {
    /*抽奖中*/
    @objc public var lotteryCall = TF_LivingRollCall()
    /**投票中*/
    @objc public var voteButton = TF_LivingRollCall()
    
    /**点名中*/
    @objc public var rollCall = TF_LivingRollCall()
    
    /**考试入口*/
    @objc public var examinationBtn = TalkfunExaminationBtn()

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //TODO:抽奖中
        self.lotteryCall.setImage(UIImage.init(named: "HTLive.bundle/liveingchoujiang"), for: .normal)
        self.lotteryCall.setTitle("抽奖", for: .normal)
        self.addSubview(self.lotteryCall)
        self.lotteryCall.isHidden = true
    
        //TODO:点名中
        self.rollCall.setImage(UIImage.init(named: "HTLive.bundle/liveingdianming"), for: .normal)
        self.rollCall.setTitle("点名", for: .normal)
        
        self.addSubview(self.rollCall)
        self.rollCall.isHidden = true
        
        
        //TODO:投票中
        self.voteButton.setImage(UIImage.init(named: "HTLive.bundle/liveingtoupiao"), for: .normal)
        self.voteButton.setTitle("投票", for: .normal)
       
        self.addSubview(self.voteButton)
        self.voteButton.isHidden = true
        
        
        //TODO:考试入口button
        self.examinationBtn.isHidden = true
        self.examinationBtn.backgroundColor = UIColor.clear
        self.addSubview(self.examinationBtn)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        let voteButtonH:CGFloat = 39 + 16
        let voteButtonY:CGFloat = self.frame.size.height - 30 - voteButtonH
        
        //投票
        self.voteButton.frame = CGRect(x: self.frame.size.width - 36 - 11, y: voteButtonY, width: 36, height: voteButtonH)
   
        var lotteryCallY:CGFloat = voteButtonY - voteButtonH - 10;

           //抽奖中
        self.lotteryCall.frame = CGRect(x: self.frame.size.width - 36 - 11, y: lotteryCallY, width: 36, height: voteButtonH)
        
        if (self.voteButton.isHidden == true) {
            lotteryCallY = self.voteButton.frame.origin.y
        }
        let rollCallY:CGFloat = lotteryCallY
        //点名中
        self.rollCall.frame = CGRect(x: self.frame.size.width - 36 - 11, y: rollCallY, width: 36, height: voteButtonH)
       
        
        let examinationBtnH:CGFloat = 40.0 + 16.0;
        let examinationBtnW:CGFloat = 42.0;
        var examinationBtnY:CGFloat = self.frame.size.height - examinationBtnH - 30.0
        //显示投票
        if (self.voteButton.isHidden == false) {
            //抽奖中
            if(self.lotteryCall.isHidden)
            {
                examinationBtnY = self.voteButton.frame.origin.y - examinationBtnH - 11
                
                //点名中
                if (self.rollCall.isHidden) {
                    
                }else
                {
                    examinationBtnY = self.rollCall.frame.origin.y - examinationBtnH - 11;
                }
            }else
            {
                //抽奖中
                examinationBtnY = self.lotteryCall.frame.origin.y - examinationBtnH - 11;
            }
            
        }
        
        self.examinationBtn.frame = CGRect(x: 0, y: examinationBtnY, width: examinationBtnW, height: examinationBtnH)
    }
    
}
